package Sort;

import java.util.Arrays;
import java.util.Random;

public class test {

    public static void orderArray(int[]array){
        for (int i = 0; i < array.length ; i++) {
         array[i]= array.length-i;
        }
    }

    public static void notOrderArray(int[]array){
        Random random=new Random();
        for (int i = 0; i < array.length ; i++) {
            array[i]=random.nextInt(10_0000);
        }
    }

    public static void testInsert(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("直接插入排序用时："+(endTime-startTime));
    }

    public static void testShell(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("希尔排序用时："+(endTime-startTime));
    }


    public static void testseletc(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.selectSort2(array);
        long endTime=System.currentTimeMillis();
        System.out.println("选择排序用时："+(endTime-startTime));
    }

    public static void testbub(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        System.out.println("排序前："+Arrays.toString(array));

        Sort.bubbleSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("排序后："+Arrays.toString(array));
        System.out.println("冒泡排序用时："+(endTime-startTime));


    }

    public static void testquick(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        System.out.println("排序前："+Arrays.toString(array));

        Sort.quickSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("排序后："+Arrays.toString(array));
        System.out.println("快速排序用时："+(endTime-startTime));
    }

    public static void testmerge(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        System.out.println("排序前："+Arrays.toString(array));

        Sort.mergeSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("排序后："+Arrays.toString(array));
        System.out.println("快速排序用时："+(endTime-startTime));
    }

    public static void testCount(int[]array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        System.out.println("排序前："+Arrays.toString(array));

        Sort.c(array);
        long endTime=System.currentTimeMillis();
        System.out.println("排序后："+Arrays.toString(array));
        System.out.println("快速排序用时："+(endTime-startTime));
    }


    public static void testSimple(){
        int[]array={2,31,1,3,42,94,653,43,3};
        System.out.println("排序前："+Arrays.toString(array));
        //Sort.shellSort(array);
    //Sort.selectSort1(array);
  //  Sort.selectSort2(array);
Sort.bubbleSort(array);
        System.out.println("排序后："+Arrays.toString(array));
    }

    public static void testOther(){
        int[]array=new int[10_0000];
        notOrderArray(array);
      //  orderArray(array);


       testbub(array);
    }


    public static void main(String[] args) {
        int[]array={2,31,1,3,42,94,653,43,3};
       // testseletc(array);
        //testbub(array);
//testSimple();
testmerge(array);
       // testquick(array);
        System.out.println("===============");
//testOther();
 //       testOther();
    }




    public static void main1(String[] args) {
        int[]arr={2,3,1,7,6,8,9};
        Sort sort=new Sort();
sort.insertSort(arr);
        System.out.println(Arrays.toString(arr));

        System.out.println("=====================");
        int []arr1={12,32,1,34,5,1,6,5,3,53};
        sort.shellSort(arr1);
        System.out.println(Arrays.toString(arr1));

    }

}
